package com.wj.rspmproperty.mapper;

import com.wj.rspmproperty.pojo.Building;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;


import java.util.List;

/**
 * @author WeiJin
 * @version 1.0
 */

public interface BuildingMapper {

    /**
     * 根据建筑物状态查询建筑
     * @param status 建筑物状态
     * @return 结果集
     */
    List<Building> buildingOfStatus(@Param("status") Integer status);

    /**
     * 新增楼栋
     * @param building
     * @return
     */
    @Insert("insert into building values(#{building_id},#{building_code},#{building_name},#{building_status}," +
            "#{building_floors},#{completed_date},#{design_life},#{ownership})")
    int addBuilding(Building building);

    /**
     * 批量添加建筑
     * @param buildings
     * @return
     */
    int insertBuildings(List<Building> buildings);

    /**
     * 批量修改建筑状态
     * @param idList
     * @param status
     * @return
     */
    int changeBuildingsStatus(List<Integer> idList, Integer status);

    /**
     * 根据楼栋id查询楼栋信息
     * @param id
     * @return
     */
    @Select("<script>" +
            "select * from building where building_id = #{id}" +
            "</script>")
    Building queryById(Integer id);
}
